package nc.ui.arap.buttonstat;

import nc.ui.arap.engine.AbstractRuntime;
import nc.ui.arap.engine.ExtButtonObject;
import nc.ui.arap.engine.IActionRuntime;
import nc.ui.arap.engine.IButtonStatus;
import nc.ui.arap.global.DjTempletHelper;
import nc.ui.ep.dj.ArapBillWorkPageConst;
import nc.vo.ep.dj.DJZBHeaderVO;
import nc.vo.ep.dj.DJZBVO;
import nc.vo.ep.dj.DJZBVOConsts;

public class DjRedStatListener implements IButtonStatus {

	public void updateButtonStatus(ExtButtonObject bo, IActionRuntime runtime) {
		// TODO Auto-generated method stub
		if(null != StatListenerHelper.getDjPanel(runtime)){
			int panelprop = StatListenerHelper.getDjPanel(runtime).getPanelProp();
			if(panelprop == 1 || panelprop == 2 || panelprop == 3 || panelprop == 4){
				bo.setVisible(false);
				return ;
			}
		}
		if(!(runtime instanceof AbstractRuntime))
			return ;
		AbstractRuntime runt=(AbstractRuntime)runtime;
		bo.setEnabled(false);
		if(!DjTempletHelper.isCardInQuery(runt)){
			return ;
		}
		if(runt.getCurrWorkPage()==ArapBillWorkPageConst.LISTPAGE){
			if (DjTempletHelper.isListSelectedBill(runt)) {
				bo.setEnabled(true);
				bo.setVisible(true);
			}
		}else{
			DJZBVO djvo = runt.getDjDataBuffer().getCurrentDJZBVO();
			if (djvo != null) {
				DJZBHeaderVO head = (DJZBHeaderVO) djvo.getParentVO();
				if (head != null) {
					if (head.getSxbz() != null
							&& (head.getSxbz().intValue() == DJZBVOConsts.m_intSXBZ_VALID)
							&& !head.getDjdl().equals("ws")
							&& !head.getDjdl().equals("wf")) {
						bo.setEnabled(true);
						bo.setVisible(true);
					}
			}
		}
	}
	}
}
